package com.mccrea.pattern.singleton.type6;

import org.omg.CORBA.PUBLIC_MEMBER;

/**
 * @Classname SingleTonTest05
 * @Description 单例模式 静态内部类
 * @Date 2021/5/7 0007 16:24
 * @Created by Mccrea_Gao
 */
public class SingleTonTest06 {
    public static void main(String[] args) {

    }
}

/**
 * 静态内部类特点， SingleTon06 加载时， SingleTonInstance不会加载，
 * 使用getInstance()才会加载SingleTonInstance，加载时线程安全
 */
class SingleTon06 {
    private SingleTon06() {

    }

    private static class SingleTonInstance {
        private static final SingleTon06 INSTANCE = new SingleTon06();
    }

    public static SingleTon06 getInstance() {
        return SingleTonInstance.INSTANCE;
    }
}
